function test_1(){
    var name = "Tangjinhu";
    var age = 24;
    var major = "intelligent_science_and_technology";
    var grade = "junior";
    console.log(`${name} 今年 ${age} 岁专业是 ${major} ，年级是 ${grade}`);

    //字符串方法
    var s = 'Where the heart desires, walk the walk。';
    console.log(s.length);
    
    console.log(s[0]);
    console.log(s.toUpperCase());
    console.log(s.toLocaleLowerCase());
    console.log(s.indexOf('heart'));
    console.log(s.substring(0,6));
    console.log(s.substring(8));

    //数组
    var person = {
        name: 'Tangjinhu',
        age: 18,
        position: ['admin', 'maneger'],
        city:'Chongqing',
        hasCar:false,
        hasHouse:false,
        zipcode:null
    };
    console.log(person);
    person.email = "23750271@qq.com"; //新增属性
    person.name = "KingTang"; //修改属性
    console.log(person.city); //获取属性
    delete person.zipcode; //删除属性
    console.log(person.hasOwnProperty('name')); //判断是否有属性
    console.log(person);

    //Map
    var m=new Map();//空Map
    m.set('Tang',24);//新增
    console.log(m);
    console.log(m.has('Adam'));//判断是否存在
    console.log(m.get('Adam'));//获取，没有返回undefined
    m.delete('Tang');//删除key
    console.log(m);

    //Set
    var s1 = new Set();//空Set
    console.log(s1.add(4)) ;
    var s2 = new Set([1, 2, 3]);//含1，2，3
    s2.delete(1)
    console.log(s2) ;

    //运算符
    console.log(1+3);
    console.log((1+2)*5/2);
    console.log(2/0);
    console.log(10%3);

    //条件运算
    var age = 45;
    if(age<18){
        alert('少年');
    }else if(age>18&&age<=40){
        alert('青壮年');
    }else {
        alert('老年');
    }

    //for循环
    var arr = ['Apple', 'Geogle', 'Microsoft','Huawei'];
    var i, x;
    for(i=0; i < arr.length; i++){
        x = arr[i];
        console.log(x);
    }

    //for in 循环数组
    var a = ['A', 'B', 'C', 'D'];
    for(var i in a){
        console.log(i); //'0','1','3'
        console.log(a[i]);//'A','B','C'
    }

    //for in 循环对象属性
    var o = {
        name: 'Jack',
        age: '20',
        city: 'New York'
    };
    for (var key in o){
        if(o.hasOwnProperty(key)){
            console.log(key); //'name','age','city'
        }
    }

    //for...of循环
    var a = ['Aada','B','C'];
    for(var x of a){
        console.log(x);
    }

    //forEach循环
    a.forEach(function(element){
        console.log(element)
    })

    var s=new Set(['fhus' ,'afgydsgf', 'agfyusa']);
    s.forEach(function(element, sameElement, set){
        console.log(element)
    });
    
    var m = new Map([[1,'x'], [2,'y'], [3,'z']]);
    m.forEach(function(value, key, map){
        console.log(value);
    });

    //函数
    console.log(Math.max.apply(null, [3, 5, 4])); // 函数 apply 方法，第一个参数为 this，第二个参数为 Array，为函数参数
    console.log(Math.max.call(null, 3, 5, 4)); // 函数 call 方法，第一个参数为 this，在函数参数依次传入
    
    //方法
    var person = {
        name:'Tangjinhu',
        birth:'1998',
        age: function() {
            var y = new Date().getFullYear();
            return y - this.birth;
        }
    };
    console.log(person.age); //function xiaoming.age()
    console.log(person.age()); //返回值

    //箭头函数
    () => 67483 ; //无参
    (num) => num; //一参
    (x, y) => x * x + y * y; //二参

    sum = (x, y, ...rest) => {
        var i, sum = x + y;
        for(i = 0; i < rest.length; i++){
            sum += rest[i];
        }
        return sum;   
    }   
    console.log(sum(1, 2, 4, 5));  

    //高阶函数
    //Array元素循环处理
    let array = [2, 45, 3, 5, 7, 9]
    array.forEach(a => console.log(a));

    //Array元素包装，返回新Array
    var arr = [1, 2, 3, 4, 5];
    var arr1 = arr.map(item => item = 2);
    for(var x of arr1){
        console.log(x);
    }
    //Array元素叠加处理
    var arr2 = arr.reduce((a,b) => a+b );
    console.log(arr2);

    //Array元素过滤处理
    var arr3 = arr.filter(item => item % 2 == 0);
    console.log(arr3);
    //Arra元素排序处理
    let arr4 = [3, 4, 1, 7, 28, 23, 18].sort((a, b) => a - b);
    console.log(arr4)

    //标准对象
    //指定日期
    var d1 = new Date(2022,6,15,17,18,30,250);
    console.log(d1);

    //字符串转日期（时间戳）
    var d2 = Date.parse('2022-06-15T17:21:40.250+08:00');
    console.log(d2);

    //时间戳转日期
    var d3 =new Date(1655284900250);
    console.log(d3);

    //RegExp
    // 正则验证
    var re = /^\d{3}\-\d{3,8}$/;
    console.log(re.test('010-12345'));
    console.log(re.test('010-1234x'));
    console.log(re.test('010 12345'));

    //字符串切割
    console.log('a b   c'.split(/\s+/));

    //分组提取
    var re = /^(\d{3})-(\d{3,8})$/;
    re.exec('010-12345'); // ['010-12345', '010', '12345']
   

    //JSON
    //序列化
    console.log(JSON.stringify(person));

    //反序列化
    console.log(JSON.parse('[1,2,3,4,5,false]'));
} 